#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

#include "include/vector.h"
#include "include/queue.h"

void QueueNew(Queue* q){
    Vector* v = malloc(sizeof(Vector)); 
    assert(v != NULL); 
    VectorNew(v); 
    q->v = v;
}

void QueueEnqueue(Queue* q, int elem){
    VectorAddLast(q->v, elem); 
}
int QueueDequeue(Queue* q){
    return VectorRemoveFirst(q->v);
}
int QueueFront(Queue* q){
    return VectorGetFirst(q->v);
}

int QueueSize(Queue* q){
    return VectorSize(q->v);
}
int QueueIsEmpty(Queue* q){
    return VectorIsEmpty(q->v);
}
void QueueString(Queue* q){
    printf("Queue:");
    printf(" > front [");
    for (int i = 0; i < QueueSize(q); i++) {
        printf("%d", VectorGet(q->v, i));
        if (i != QueueSize(q) - 1)
            printf(", ");
    }
    printf("] tail\n"); 
} 

void QueueDispose(Queue* q){
    if (q->v) {
        VectorDispose(q->v);
        free(q->v); 
    }
} 
